#pragma once
#include "..\BaseGameComponent.h"
#include "..\Delegate.h"
#include <vector>

using namespace std;

typedef void(*addObject_event_handler)(void**);

class GameObject;
struct Agent;

// keeps track of all objects inside a world chunk
class ObjectManager : public BaseGameComponent
{ 
	vector<GameObject*> objects;

	vector<Agent*> agents;

public:
	ObjectManager(void);
	virtual ~ObjectManager(void);

	/////////////////////<events>//////////////////////////////////////////
	
	/////////////////////<abstract functions>//////////////////////////////////////////

	virtual void Update(float dt) override;

	virtual void Draw(void) override;

	/////////////////////<public functions>//////////////////////////////////////////

	// adds the provided object to the collection
	void AddObject(GameObject* object);

	// adds an agent to the agent collection
	void AddAgent(Agent* agent);

	// retrieve an agent from 'index'
	Agent* getAgent(int index) { return agents[index]; }

	// retrieve the game object at 'index'
	GameObject* getObject(int index) { return objects[index]; }

	// gets the number of objects in the collection
	unsigned int getNumObjects(void) const { return objects.size(); }

	// gets the number of agents in the collection
	unsigned int getNumAgents(void) const { return agents.size(); }

	// finds the object in the collection removes it and returns true if the object is found.
	// Returns false if the object is not found.
	bool RemoveObject(GameObject* object);

	// Same as 'RemoveObject' but removes at a specified index
	void RemoveAt(int index);
};